#include"processbar.h"
#include<string.h>
#include<unistd.h>

#define Length 101
#define Style '#'
const char *lable = "|/-\\";
void Procbar(double total,double current)
{
  char bar[Length];
  memset(bar,'\0',sizeof(bar));
  int len = strlen(lable);
  int cnt = 0;
  double rate = (current * 100.0)/total; 
  int loop_count = (int)rate;
  while(cnt <= loop_count)
  {
   // printf("[%-100s][%.1f%][%c]\r",bar,rate,lable[cnt%len]);
   // fflush(stdout);
    bar[cnt++] = Style;
  }
    printf("[%-100s][%.1f%][%c]\r",bar,rate,lable[cnt%len]);
    fflush(stdout);
}
